package com.neutech.convert;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

//编写一个字符串转换成日期的springmvc转换器类,选择core下的实现接口,手写添加泛型<String,java.util.Date>，重写方法
@Component
public class StringToDateConvert implements Converter<String,java.util.Date>{

	@Override
	public Date convert(String source) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		try {
			Date date = sdf.parse(source);
			return date;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}



}
